<template>
  <div id="htPage">
    <div class="content">
      <!-- <div class="top" v-if="isshowsss">
      <img
        style="width: 80%; margin: 0 auto"
        src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/ZLJ/xian.png"
      />
      <p>
        <span
          :class="showMoble ? '' : 'PADD1'"
          style="width: 22%; display: inline-block; text-align: center"
          >申请</span
        >
        <span style="width: 26%; display: inline-block; text-align: center"
          >选图选工匠</span
        >
        <span style="width: 25%; display: inline-block; text-align: center"
          >签订合同</span
        >
        <span
          :class="showMoble ? '' : 'PADD2'"
          style="width: 21%; display: inline-block; text-align: center"
          >竣工验收</span
        >
      </p>
    </div> -->
      <div class="list">
        <van-form validate-first>
          <p class="subTitle"><span class="line"></span>合同基本信息</p>
          <div>
            <!-- <van-field :readonly='isread' clickable name="picker" v-model="sexName" label="性别" placeholder="请选择性别" @click="ENUM.XB = true" /> -->
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].FBR"
                label="发包人"
                placeholder="请填写发包人"
              />
            </div>
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].JMSFZHM"
                label="身份证号"
                placeholder="请填写身份证号"
              />
            </div>
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].LXDH"
                label="联系电话"
                placeholder="请填写手机号"
              />
            </div>
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].TXDZ"
              label="通讯地址"
              placeholder="请填写户口所在地"
            />
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].CBR"
                label="承包人"
                placeholder="请填写承包人姓名"
              />
            </div>
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].CBRTXDZ"
              label="承包人通讯地址"
              placeholder="请填写承包人通讯地址"
            />
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].CBRJMSFZJM"
                label="承包人居民身份证号码"
                placeholder="请填写承包人居民身份证号码"
              />
            </div>
            <div
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                color: black;
              "
            >
              <span style="color: #ff0000">*</span>
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].CBRLXDH"
                label="承包人联系电话"
                placeholder="请填写承包人联系电话"
              />
            </div>
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].GJTXDZ"
              label="工匠通讯地址"
              placeholder="请填写工匠通讯地址"
            />
          </div>
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].YZBM"
              label="邮政编码"
              placeholder="请填写邮政编码"
            />
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].YZLXDH"
              label="邮政联系电话"
              placeholder="请填写邮政联系电话"
            />
            <div v-if="isPerTab">
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].TYSHXYDM"
                label="统一社会信用代码"
                placeholder="请填写统一社会信用代码"
              />
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].QYZZZSH"
                label="企业资质证书号"
                placeholder="请填写企业资质证书号"
              />
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].FDDBR"
                label="法人代表人"
                placeholder="请填写法人代表人"
              />
              <van-field
                :readonly="isread"
                v-model="SHOWData[0].FDLXDH"
                label="法定联系电话"
                placeholder="请填写法定联系电话"
              />
            </div>
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].WTDLR"
              label="委托代理人"
              placeholder="请填写委托代理人"
            />
            <van-field
              :readonly="isread"
              v-model="SHOWData[0].WTLXDH"
              label="委托联系电话"
              placeholder="请填写委托联系电话"
            />
          <p class="subTitle"><span class="line"></span>建房概况</p>
          <div>
            <van-field
              v-model="SHOWData[0].JFDD"
              label="建房地点"
              placeholder="请填写建房地点"
            />
            <!-- <van-field
              v-model="SHOWData[0].JFGM"
              label="建房规模"
              placeholder="请填写建房规模"
            /> -->
            <van-field
              readonly
              clickable
              name="picker"
              :value="JFGM"
              label="建房规模"
              placeholder="建房规模"
              @click="showPickerJFGM = true"
              :rules="[{ required: true, message: '建房规模' }]"
            />
            <van-popup v-model="showPickerJFGM" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="CityColumnJFGM"
                value-key="DICNAME"
                @confirm="onConfirmJFGM"
                @cancel="showPickerJFGM = false"
              />
            </van-popup>
            <van-field
              v-model="SHOWData[0].ZJZMJ"
              label="总建筑面积"
              placeholder="请填写总建筑面积"
            />
            <!-- <van-field
              v-model="SHOWData[0].JGXSKJJG"
              label="结构形式其他"
              placeholder="请填写结构形式其他(请填写数字)"
            /> -->
            <van-field
              readonly
              clickable
              name="picker"
              :value="JGXSKJJG"
              label="结构形式其他"
              placeholder="结构形式其他"
              @click="showPickerC = true"
              :rules="[{ required: true, message: '结构形式其他' }]"
            />
            <van-popup v-model="showPickerC" position="bottom" get-container="#popup">
              <van-picker
                show-toolbar
                :columns="CityColumns"
                value-key="DICNAME"
                @confirm="onConfirmTown"
                @cancel="showPickerC = false"
              />
            </van-popup>
            <van-field
              v-model="SHOWData[0].ZJDYDPZWJWH"
              label="宅基地用地批准文件文号"
              placeholder="请填写宅基地用地批准文件文号"
            />
            <van-field
              v-model="SHOWData[0].XCJSGHXKZH"
              label="乡村建设规划许可证号"
              placeholder="请填写乡村建设规划许可证号"
            />
            <van-field
              v-model="SHOWData[0].JDR"
              label="地基基础验收合格几日"
              placeholder="请填写地基基础验收合格几日"
            />
            <van-field
              v-model="SHOWData[0].JDR1"
              label="地上一层验收合格几日"
              placeholder="请填写地上一层验收合格几日"
            />
            <van-field
              v-model="SHOWData[0].JDR2"
              label="地上二层验收合格几日"
              placeholder="请填写地上二层验收合格几日"
            />
            <van-field
              v-model="SHOWData[0].JDR3"
              label="地上三层验收合格几日"
              placeholder="请填写地上三层验收合格几日"
            />
          </div>
        </van-form>
      </div>
      <p class="subTitle"><span class="line"></span>承包内容和方式</p>
      <!-- <van-field
        v-model="SHOWData[0].SJQT"
        label="设计其他内容"
        placeholder="请填写设计其他内容"
      /> -->
      <van-field
        readonly
        clickable
        name="picker"
        :value="DJJC"
        label="设计其他内容"
        placeholder="设计其他内容"
        @click="showPickerX = true"
      />
      <van-popup v-model="showPickerX" position="bottom" get-container="#popup">
        <van-picker
          show-toolbar
          :columns="CityColumns1"
          value-key="DICNAME"
          @confirm="onConfirmXian"
          @cancel="showPickerX = false"
        />
      </van-popup>
      <!-- <van-field
        v-model="SHOWData[0].SJQTNR"
        label="承包方式其他"
        placeholder="请填写承包方式其他"
      /> -->
      <van-field
        readonly
        clickable
        name="picker"
        :value="DJJC1"
        label="承包方式其他"
        placeholder="承包方式其他"
        @click="showPickerY = true"
      />
      <van-popup v-model="showPickerY" position="bottom" get-container="#popup">
        <van-picker
          show-toolbar
          :columns="CityColumns2"
          value-key="DICNAME"
          @confirm="onConfirmXian1"
          @cancel="showPickerY = false"
        />
      </van-popup>
      <p class="subTitle"><span class="line"></span>合同工期</p>
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].GQZRLTS"
        label="总日历天数"
        placeholder="总日历天数"
      />
      <!-- <van-field v-model="SHOWData[0].JHKGRQ" label="计划开工日期" placeholder="计划开工日期" /> -->
      <van-field
        readonly
        clickable
        name="datetimePicker"
        :value="SHOWData[0].JHKGRQ"
        label="计划开工日期"
        placeholder="请选计划开工日期"
        @click="showPickerq2 = true"
      />
      <van-popup v-model="showPickerq2" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="date"
          title="选择年月日"
          @cancel="showPickerq2 = false"
          @confirm="onConfirmRQ2"
        />
      </van-popup>
      <!-- <van-field v-model="SHOWData[0].JHJGRQ" label="计划竣工日期" placeholder="计划竣工日期" /> -->
      <van-field
        readonly
        clickable
        name="datetimePicker"
        :value="SHOWData[0].JHJGRQ"
        label="计划竣工日期"
        placeholder="请选计划竣工日期"
        @click="showPickerq1 = true"
      />
      <van-popup v-model="showPickerq1" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="date"
          title="选择年月日"
          @cancel="showPickerq1 = false"
          @confirm="onConfirmRQ1"
        />
      </van-popup>
      <p class="subTitle"><span class="line"></span>价款支付和费用承担</p>
      <van-field
        v-model="SHOWData[0].ZJK"
        label="总价款大写"
        placeholder="请填写总价款大写"
      />
      <van-field
        v-model="SHOWData[0].ZJKXX"
        label="总价款小写"
        placeholder="请填写总价款小写"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].KGZFDX"
        label="开工支付(大写)"
        placeholder="开工支付(大写)"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].KGZFXX"
        label="开工支付（小写）"
        placeholder="开工支付（小写）"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].QTZFFS"
        label="其他支付方式"
        placeholder="其他支付方式"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DJYHZFDX"
        label="地基验收支付（大写）"
        placeholder="地基验收支付（大写）"
      />
      <!-- <van-field
        :readonly="isread"
        v-model="SHOWData[0].DJJC"
        label="地基基础"
        placeholder="地基基础"
      /> -->
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSYCYHXX"
        label="地上一层"
        placeholder="地上一层"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSECYHXX"
        label="地上二层"
        placeholder="地上二层"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSSCYHXX"
        label="地上三层"
        placeholder="地上三层"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].JTN"
        label="几天内"
        placeholder="几天内"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DJYHZFXX"
        label="地基验收支付（小写）"
        placeholder="地基验收支付（小写）"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSYCYHDX"
        label="地上一层验收（大写)"
        placeholder="地上一层验收（大写"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSECYHDX"
        label="地上二层验收（大写）"
        placeholder="地上二层验收（大写）"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DSSCYSDX"
        label="地上三层验收（大写）"
        placeholder="地上三层验收（大写）"
      />
      <p class="subTitle"><span class="line"></span>施工要求</p>
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].KGJR"
        label="开工几日"
        placeholder="开工几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].TQJR"
        label="提前几日"
        placeholder="提前几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].ZTJGJN"
        label="主体结构几年"
        placeholder="主体结构几年"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].QMFSJN"
        label="墙面防渗几年"
        placeholder="墙面防渗几年"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].DQPSGD"
        label="电器排水管道几年"
        placeholder="电器排水管道几年"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].TZQR"
        label="通知日几日"
        placeholder="通知日几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].YDJR"
        label="应当几日"
        placeholder="应当几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].ZSTZJR"
        label="自收通知几日"
        placeholder="自收通知几日"
      />
      <p class="subTitle"><span class="line"></span>违约责任</p>
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].WYJ"
        label="万分之"
        placeholder="万分之"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].MRJY2"
        label="每日几元"
        placeholder="每日几元"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].YQJR"
        label="逾期几日"
        placeholder="逾期几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].YWJR"
        label="延误几日"
        placeholder="延误几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].YHHGJR"
        label="验收合格几日"
        placeholder="验收合格几日"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].JSQDJR"
        label="结算清单几日"
        placeholder="结算清单几日"
      />
      <p class="subTitle"><span class="line"></span>争议解决</p>
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].SQZC"
        label="申请仲裁"
        placeholder="申请仲裁"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].RMFYQS"
        label="人民法院起诉"
        placeholder="人民法院起诉"
      />
      <van-field
        readonly
        clickable
        name="picker"
        :value="DJJCZY"
        label="争议解决仲裁委员会申请仲裁"
        placeholder="争议解决仲裁委员会申请仲裁"
        @click="showPickerZY = true"
      />
      <van-popup v-model="showPickerZY" position="bottom" get-container="#popup">
        <van-picker
          show-toolbar
          :columns="CityColumnsZY"
          value-key="DICNAME"
          @confirm="onConfirmZY"
          @cancel="showPickerZY = false"
        />
      </van-popup>
      <p class="subTitle"><span class="line"></span>其他事项</p>
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].BR"
        label="本人"
        placeholder="本人"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].FBRHT"
        label="发包人合同"
        placeholder="发包人合同"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].CBRHT"
        label="承包人合同"
        placeholder="承包人合同"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].FBRQZHGZ"
        label="发包人（签字或盖章）"
        placeholder="发包人（签字或盖章）"
      />
      <van-field
        :readonly="isread"
        v-model="SHOWData[0].CBRQZHGZ"
        label="承包人（签字或盖章）"
        placeholder="承包人（签字或盖章）"
      />
    </div>
    <div class="footer">
      <!-- <van-button style="margin-right: 10px;" size="small" type="info" @click="getinsertDataView">提交</van-button> -->
      <van-button
        style="width: 20vw;"
        size="small"
        type="info"
        @click="save"
        >保存</van-button
      >
      <van-button
        style="width: 20vw;"
        size="small"
        type="info"
        @click="GotoPff"
        >预览</van-button
      >
    </div>
    <div></div>
  </div>
</template>
<script>
import {
  updateDataView,
  FileServerUpload,
  InsertDataView,
  dataServerOpenDataView,
  CreateProcessAndSendTask,
  GetFileData,
  DelectFile,
  QuerySignCallback,
  FileServerProxy,
} from "../../utils/api";
import { v4 as uuidv4 } from "uuid";
export default {
  data() {
    return {
      hideMap: true,
      isread: false,
      isshowsss:false,
      MapUrl: "",
      isPerTab: false,
      NYD: "",
      DL: "",
      JFLX: "",
      showPickerC: false,
      className: "",
      JFGM:'',
      showPickerJFGM:false,
      showMoble:'',
      showPicker1: false,
      showPicker2: false,
      showPicker3: false,
      isShowTK: false,
      isShowCH: false,
      baseUrl: window.g.BaseURL,
      //存储需要传给treeSelect组件的值
      SaveCHDW: [],
      SaveTKDW: [],
      CityColumnJFGM:[
      {
          DICID: '552',
          DICNAME: '一'
        },
        {
          DICID: '553',
          DICNAME: '二'
        },
        {
          DICID: '554',
          DICNAME: '三'
        },
        {
          DICID: '555',
          DICNAME: '四'
        },
        {
          DICID: '556',
          DICNAME: '五'
        },
        {
          DICID: '557',
          DICNAME: '六'
        },
        {
          DICID: '558',
          DICNAME: '七'
        },
        {
          DICID: '559',
          DICNAME: '八'
        },
        {
          DICID: '560',
          DICNAME: '九'
        },
        {
          DICID: '561',
          DICNAME: '十'
        }
      ],
      SHOWData: [
        {
          FBR: "",
          JGXSKJJG: "",
          DJJC: "",
          SJQTNR: "",
          JMSFZHM:"",
          LXDH:"",
          CBR:"",
          CBRJMSFZJM:"",
          CBRLXDH:"",
          ZYJJ:""
        },
      ],
      showPickerq: false,
      showPickerq1: false,
      showPickerq2: false,
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2025, 10, 1),
      currentDate: new Date(),
      fileList: [],
      //踏勘单位
      TKDW: [],
      //测绘单位
      CHDW: [],
      valueZhen: "",
      valueZhen1: "",
      TownColumns: [],
      TownColumns1: [],
      showPickerT1: false,
      showPickerT: false,
      Canshu: 0,
      ENUM: {
        XB: false,
        XBARR: [],
        SF: false,
        SF1: false,
        SF2: false,
        SFARR: [],
        SFARR1: [],
        SFARR2: [],
        NYD: false,
        NYDARR: [],
        JFLX: false,
        JFLXARR: [],
        YDLX: false,
        YDLXARR: [],
        JGLX: false,
        JGLXARR: [],
        WSCLFS: false,
        WSCLFSARR: [],
      },
      isSaveFile: false,
      CityColumns: [],
      CityColumns1: [],
      CityColumns2: [],
      CityColumnsZY: [],
      showPickerX: false,
      showPickerY: false,
      showPickerZY: false,
      JGXSKJJG: "",
      sexName: "",
      DJJC1: "",
      DJJC: "",
      DJJCZY: "",
    };
  },
  watch: {},
  filters: {
    inUseName: function (msg, data) {
      let name = "";
      data.forEach((item) => {
        if (item.DICID == msg) {
          name = item.DICNAME;
        }
      });
      return name;
    },
  },
  mounted() {
    if(JSON.parse(window.sessionStorage.getItem('fileData'))?.S){
        this.isshowsss = false
    } else {
        this.isshowsss = true
    }
    document.getElementsByTagName('html')[0].style.overflowX = 'visible'
    this.isPerTab =
    window.localStorage.getItem("isPerTab") == "1" ? false : true;
    this.getJFLYOpenDataView();
    this.getJFLYOpenDataView1();
    this.getJFLYOpenDataView2();
    this.getJFLYOpenDataViewZY();
    this.getData1();
    // this.getData()
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: "合同",
      })
        .then((res) => {
        })
        .catch((err) => {
        });
    }
    setTimeout(() => {
      try{
        this.CityColumns.forEach((item) => {
        if (item.DICID == this.SHOWData[0].JGXSKJJG) {
          this.JGXSKJJG = item.DICNAME;
        }
      });
      } catch(err){
        
      }
      this.CityColumns1.forEach((item) => {
        if (item.DICID == this.SHOWData[0].DJJC) {
          this.DJJC = item.DICNAME;
        }
      });
      this.CityColumns2.forEach((item) => {
        if (item.DICID == this.SHOWData[0].SJQTNR) {
          this.DJJC1 = item.DICNAME;
        }
      });
      this.CityColumnsZY.forEach((item) => {
        if (item.DICID == this.SHOWData[0].ZYJJ) {
          this.DJJCZY = item.DICNAME;
        }
      });
      this.CityColumnJFGM.forEach((item) => {
        if (item.DICID == this.SHOWData[0].JFGM) {
          this.JFGM = item.DICNAME;
        }
      });
    }, 1000);
  },
  methods: {
    //回显数据
    //点击列表签订合同打开前端写的合同界面，先调用查询接口(接口1),判断如果有数据，就回显查询接口的合同内容。同时点击保存合同信息因调用修改接口(接口2)，如果没有数据就回显接口（接口3）的数据，
    //同时保存应掉新增接口（接口4）
    //接口1
    onConfirmTown(value) {
      this.JGXSKJJG = value.DICNAME;
      this.SHOWData[0].JGXSKJJG = value.DICID;
      this.showPickerC = false;
    },
    onConfirmJFGM(value){
      this.JFGM = value.DICNAME;
      this.SHOWData[0].JFGM = value.DICID;
      this.showPickerJFGM = false;
    },
    getJFLYOpenDataView: async function () {
      this.CityColumns = [];
      let dataGuid = "3c2683be-4f1c-4299-8803-b8c0d2bab9ae";
      let searchObject = [];
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",
        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: {
          dataGuid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CityColumns = eval("(" + res.data.data + ")").Data;
    },
    onConfirmXian(value) {
      this.DJJC = value.DICNAME;
      this.SHOWData[0].DJJC = value.DICID;
      this.showPickerX = false;
    },
    onConfirmZY(value) {
      this.DJJCZY = value.DICNAME;
      this.SHOWData[0].ZYJJ = value.DICID;
      this.showPickerZY = false;
    },
    getJFLYOpenDataView1: async function () {
      this.CityColumns1 = [];
      let dataGuid = "5613422e-6832-4ff8-92fd-dac1168fb066";
      let searchObject = [];
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",

        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: {
          dataGuid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CityColumns1 = eval("(" + res.data.data + ")").Data;
    },
    getJFLYOpenDataViewZY: async function () {
      this.CityColumnsZY = [];
      let dataGuid = "9a66abb6-2179-47a5-b6f9-46577ac5c947";
      let searchObject = [];
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",

        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: {
          dataGuid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CityColumnsZY = eval("(" + res.data.data + ")").Data;
    },
    onConfirmXian1(value) {
      this.DJJC1 = value.DICNAME;
      this.SHOWData[0].SJQTNR = value.DICID;
      this.showPickerY = false;
    },
    getJFLYOpenDataView2: async function () {
      this.CityColumns2 = [];
      let dataGuid = "9acbb94c-bc3c-4d8e-add9-497106d242b9";
      let searchObject = [];
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",

        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: {
          dataGuid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      const res = await QuerySignCallback(params);
      this.CityColumns2 = eval("(" + res.data.data + ")").Data;
    },
    getData1: async function () {
      let paramsData1 = {};
      paramsData1.procName = "up_contract";
      if(this.$store.state.VERSIONNUMBER == 1){
        paramsData1.procName = "up_contractv2";
      }
      paramsData1.dtParams = JSON.stringify([
        {
          I_USERID:
            "'" +

            JSON.parse(window.sessionStorage.getItem("rowData")).ROW_GUID +
            "'",
          TYPE: 1,
        },
      ]);
      paramsData1.token = window.localStorage.getItem("token");
      let paer1 = {
        accessCode: "69db6bece3a7480592e2ec753d1e335e",
        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: paramsData1,
      };

      const req1 = await FileServerProxy(paer1);
      let reqData1 = JSON.parse(req1.data.data).Data;
      this.SHOWData = [];
      if (reqData1.length == 0) {
        //自动生成uuid  let uuid = uuidv4()
        this.Canshu = 1; //走保存0走更新
        let paramsData = {};
        paramsData.procName = "up_contract";
        if(this.$store.state.VERSIONNUMBER == 1){
          paramsData.procName = "up_contractv2";
        }
        paramsData.dtParams = JSON.stringify([
          {
            I_USERID:
              "'" +
              JSON.parse(window.sessionStorage.getItem("rowData")).ROW_GUID +
              "'",
            TYPE: 3,
          },
        ]);
        paramsData.token = window.localStorage.getItem("token");
        let paer1 = {
          accessCode: "69db6bece3a7480592e2ec753d1e335e",
          cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
          params: paramsData,
        };
        let Base64 = require("js-base64").Base64;
        const req = await FileServerProxy(paer1);
        let reqData = JSON.parse(req.data.data).Data;
        // reqData[0].CBRJMSFZJM = Base64.decode(reqData[0].CBRJMSFZJM)
        // reqData[0].CBRLXDH = Base64.decode(reqData[0].CBRLXDH)
        this.SHOWData.push(this.deleteInvalid(reqData[0]));
      } else {
        this.Canshu = 0;
        this.SHOWData.push(this.deleteInvalid(reqData1[0]));
      }
      window.sessionStorage.setItem('CBRS',this.SHOWData[0].CBR)
    },

    deleteInvalid(obj) {
      Object.keys(obj).forEach((item) => {
        if (!obj[item] && obj[item] != 0) {
          delete obj[item];
        }
      });
      return obj;
    },
    onConfirmRQ1(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.className = "timeClass";
      this.SHOWData[0].JHJGRQ = `${year}-${month}-${day}`;
      this.showPickerq1 = false;
    },
    onConfirmRQ2(val) {
      let year = val.getFullYear();
      let month = val.getMonth() + 1;
      let day = val.getDate();
      let hour = val.getHours();
      let minute = val.getMinutes();
      if (month >= 1 && month <= 9) {
        month = `0${month}`;
      }
      if (day >= 1 && day <= 9) {
        day = `0${day}`;
      }
      if (hour >= 0 && hour <= 9) {
        hour = `0${hour}`;
      }
      if (minute >= 0 && minute <= 9) {
        minute = `0${minute}`;
      }
      this.className = "timeClass";
      this.SHOWData[0].JHKGRQ = `${year}-${month}-${day}`;
      this.showPickerq2 = false;
    },
    getData: async function () {
      let dataGuid = "e83485a7-0e53-40b9-b881-cf184792be89";
      let searchObject = JSON.stringify([
        {
          field: "to_row_guid",
          value: JSON.parse(window.sessionStorage.getItem("rowData")).ROW_GUID,
          operator: "=",
        },
      ]);
      let token = window.localStorage.getItem("token");
      let params = {
        accessCode: "688bd3883572440a859dfd8ba9194e7b",

        cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
        params: {
          dataGuid: dataGuid,
          searchObject: searchObject,
          token: token,
        },
      };
      let Base64 = require("js-base64").Base64;
      const res = await QuerySignCallback(params);
      if (JSON.parse(res.data.data).Data.length != 0) {
        // JSON.parse(res.data.data).Data[0].CBRJMSFZJM = Base64.decode(JSON.parse(res.data.data).Data[0].CBRJMSFZJM)
        // JSON.parse(res.data.data).Data[0].CBRLXDH = Base64.decode(JSON.parse(res.data.data).Data[0].CBRLXDH)
        this.SHOWData.push(JSON.parse(res.data.data).Data[0]);
      } else {
      }
      debugger
      window.sessionStorage.setItem('CBRS',this.SHOWData[0].CBR)
    },
    getNowTime: function () {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm =
        new Date().getMonth() + 1 < 10
          ? "0" + (new Date().getMonth() + 1)
          : new Date().getMonth() + 1;
      let dd =
        new Date().getDate() < 10
          ? "0" + new Date().getDate()
          : new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      return dateTime;
    },
    // 保存
    save: async function (type) {
      let newArr = this.SHOWData[0];

      if (
        newArr.FBR != "" &&
        newArr.JMSFZHM != "" &&
        newArr.LXDH != "" &&
        newArr.CBR != "" &&
        newArr.CBRJMSFZJM != "" &&
        newArr.CBRLXDH != ""
      ) {
        if (this.Canshu == 1) {
          //新增
          // let uuid = uuidv4()
          this.SHOWData[0].TO_ROW_GUID = JSON.parse(
            window.sessionStorage.getItem("rowData")
          ).ROW_GUID;
          delete this.SHOWData[0].PKID;
          var accessCode = "00b87f486f8b11ecacdb8c8caa46b312";
        } else {
          //修改
          var accessCode = "77ad6c1591e54d4fbc45ecc90374a2a2";
        }
        this.SHOWData[0].JGXSKJJG = Number(this.SHOWData[0].JGXSKJJG);
        let params = {
          accessCode: accessCode,

          cityCode: window.localStorage.getItem('isGJM') == 'true'?window.localStorage.getItem("citycode"):window.localStorage.getItem("citycodeChange"),
          params: {
            dataGuid: "e83485a7-0e53-40b9-b881-cf184792be89",
            strParams: JSON.stringify(this.SHOWData),
            token: window.localStorage.getItem("token"),
          },
        };
        const res = await QuerySignCallback(params);
        if (JSON.parse(res.data.data).Success) {
          setTimeout(()=>{
            this.$toast.success("保存成功");
          },500)
          this.getData1();
        } else {
          this.$toast.fail("保存失败");
        }
      } else {
        this.$toast.fail("请填写必填项");
      }
    },
    CheckIsAndroid() {
      var browser = {
        versions: (function () {
          var u = navigator.userAgent,
            app = navigator.appVersion;
          return {
            //移动终端浏览器版本信息
            ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
            android: u.indexOf("Android") > -1 || u.indexOf("Linux") > -1, //android终端或uc浏览器 //u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
            iPhone: u.indexOf("iPhone") > -1, //是否为iPhone或者QQHD浏览器
            iPad: u.indexOf("iPad") > -1, //是否iPad
          };
        })(),
      };
      if (browser.versions.android) return true;
      return false;
    },
    //预览合同
    GotoPff() {
      if (this.CheckIsAndroid()) {
        this.$router.push({
          path: "./viewPDF",
          query: {
            data:
              "https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B21D9D29E-CB7B-4015-8510-1426351C5C88%7D&toRowGuid=" +
              this.SHOWData[0].ROW_GUID +
              "&dataGuid=e83485a7-0e53-40b9-b881-cf184792be89",
          },
        });
      } else {
        ZWJSBridge.openLink({
          url:
            "https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B21D9D29E-CB7B-4015-8510-1426351C5C88%7D&toRowGuid=" +
            this.SHOWData[0].ROW_GUID +
            "&dataGuid=e83485a7-0e53-40b9-b881-cf184792be89",
        })
          .then((res) => {})
          .catch((err) => {
            window.open(
              "https://nfzjszlb.jst.zj.gov.cn/PrintServer/api/PreviewWordRpt?groupGuid=%7B21D9D29E-CB7B-4015-8510-1426351C5C88%7D&toRowGuid=" +
                this.SHOWData[0].ROW_GUID +
                "&dataGuid=e83485a7-0e53-40b9-b881-cf184792be89"
            );
          });
      }
    },
  },
};
</script>
<style lang="scss">
#htPage {
  height: 92vh;
  overflow: auto;
  background: #ffffff;
  font-size: 14px;
  .van-field__label {
    font-weight: bold;
  }
  .title {
    width: 100%;
    height: 50px;
    background: #007aff;
    line-height: 50px;
    text-align: center;
    color: #ffffff;
    font-size: 20px;
    position: relative;
  }
  .top {
    height: 50px;
    background: #ffffff;
    margin-bottom: 20px;
    padding-top: 10px;
    text-align: center;
    font-size: 14px;
  }
  .content {
    width: 100%;
    height: calc(100% - 50px);
    overflow: auto;
    padding: 10px;
    .subTitle {
      width: 100%;
      height: 50px;
      line-height: 50px;
      font-size: 20px;
      position: relative;
      display: flex;
      align-items: center;
      border-bottom: 1px solid #9b9b9b;
      padding-left: 10px;
      .line {
        width: 6px;
        height: 26px;
        background: #3f8ffc;
        display: inline-block;
        margin-right: 10px;
      }
    }
  }
  .inputWrap {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid #ebedf0;
  }
  .footer {
    display: flex;
    justify-content: space-around;
    // z-index: 9999999999999;
  }
    .top {
    // height: 40px;
    background: #ffffff;
    // margin-bottom: 20px;
    // padding-top: 25px;
    text-align: center;
    .origin {
      width: 22px;
      height: 22px;
      background: #007aff;
      border-radius: 50%;
      display: inline-block;
    }
    .line {
      width: 20vw;
      /*height: 1px;*/
      border: 1px dashed #007aff;
      display: inline-block;
    }
  }
}
</style>
